/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.esmp.sysml.componentmodel.profile.rtos.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.uml2.uml.Port;
import org.esmp.sysml.componentmodel.profile.rtos.RTOSPackage;
import org.esmp.sysml.componentmodel.profile.rtos.RunnablePort;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Runnable Port</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.esmp.sysml.componentmodel.profile.rtos.impl.RunnablePortImpl#getBase_Port <em>Base Port</em>}</li>
 *   <li>{@link org.esmp.sysml.componentmodel.profile.rtos.impl.RunnablePortImpl#getQueueSize <em>Queue Size</em>}</li>
 *   <li>{@link org.esmp.sysml.componentmodel.profile.rtos.impl.RunnablePortImpl#isBlocking <em>Blocking</em>}</li>
 *   <li>{@link org.esmp.sysml.componentmodel.profile.rtos.impl.RunnablePortImpl#isWaking <em>Waking</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RunnablePortImpl extends EObjectImpl implements RunnablePort {
	/**
	 * The cached value of the '{@link #getBase_Port() <em>Base Port</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBase_Port()
	 * @generated
	 * @ordered
	 */
	protected Port base_Port;

	/**
	 * The default value of the '{@link #getQueueSize() <em>Queue Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getQueueSize()
	 * @generated
	 * @ordered
	 */
	protected static final int QUEUE_SIZE_EDEFAULT = 1;

	/**
	 * The cached value of the '{@link #getQueueSize() <em>Queue Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getQueueSize()
	 * @generated
	 * @ordered
	 */
	protected int queueSize = QUEUE_SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #isBlocking() <em>Blocking</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isBlocking()
	 * @generated
	 * @ordered
	 */
	protected static final boolean BLOCKING_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isBlocking() <em>Blocking</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isBlocking()
	 * @generated
	 * @ordered
	 */
	protected boolean blocking = BLOCKING_EDEFAULT;

	/**
	 * The default value of the '{@link #isWaking() <em>Waking</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isWaking()
	 * @generated
	 * @ordered
	 */
	protected static final boolean WAKING_EDEFAULT = true;

	/**
	 * The cached value of the '{@link #isWaking() <em>Waking</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isWaking()
	 * @generated
	 * @ordered
	 */
	protected boolean waking = WAKING_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RunnablePortImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return RTOSPackage.Literals.RUNNABLE_PORT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Port getBase_Port() {
		if (base_Port != null && base_Port.eIsProxy()) {
			InternalEObject oldBase_Port = (InternalEObject)base_Port;
			base_Port = (Port)eResolveProxy(oldBase_Port);
			if (base_Port != oldBase_Port) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, RTOSPackage.RUNNABLE_PORT__BASE_PORT, oldBase_Port, base_Port));
			}
		}
		return base_Port;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Port basicGetBase_Port() {
		return base_Port;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBase_Port(Port newBase_Port) {
		Port oldBase_Port = base_Port;
		base_Port = newBase_Port;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RTOSPackage.RUNNABLE_PORT__BASE_PORT, oldBase_Port, base_Port));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getQueueSize() {
		return queueSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setQueueSize(int newQueueSize) {
		int oldQueueSize = queueSize;
		queueSize = newQueueSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RTOSPackage.RUNNABLE_PORT__QUEUE_SIZE, oldQueueSize, queueSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isBlocking() {
		return blocking;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBlocking(boolean newBlocking) {
		boolean oldBlocking = blocking;
		blocking = newBlocking;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RTOSPackage.RUNNABLE_PORT__BLOCKING, oldBlocking, blocking));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isWaking() {
		return waking;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWaking(boolean newWaking) {
		boolean oldWaking = waking;
		waking = newWaking;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RTOSPackage.RUNNABLE_PORT__WAKING, oldWaking, waking));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case RTOSPackage.RUNNABLE_PORT__BASE_PORT:
				if (resolve) return getBase_Port();
				return basicGetBase_Port();
			case RTOSPackage.RUNNABLE_PORT__QUEUE_SIZE:
				return getQueueSize();
			case RTOSPackage.RUNNABLE_PORT__BLOCKING:
				return isBlocking();
			case RTOSPackage.RUNNABLE_PORT__WAKING:
				return isWaking();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case RTOSPackage.RUNNABLE_PORT__BASE_PORT:
				setBase_Port((Port)newValue);
				return;
			case RTOSPackage.RUNNABLE_PORT__QUEUE_SIZE:
				setQueueSize((Integer)newValue);
				return;
			case RTOSPackage.RUNNABLE_PORT__BLOCKING:
				setBlocking((Boolean)newValue);
				return;
			case RTOSPackage.RUNNABLE_PORT__WAKING:
				setWaking((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case RTOSPackage.RUNNABLE_PORT__BASE_PORT:
				setBase_Port((Port)null);
				return;
			case RTOSPackage.RUNNABLE_PORT__QUEUE_SIZE:
				setQueueSize(QUEUE_SIZE_EDEFAULT);
				return;
			case RTOSPackage.RUNNABLE_PORT__BLOCKING:
				setBlocking(BLOCKING_EDEFAULT);
				return;
			case RTOSPackage.RUNNABLE_PORT__WAKING:
				setWaking(WAKING_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case RTOSPackage.RUNNABLE_PORT__BASE_PORT:
				return base_Port != null;
			case RTOSPackage.RUNNABLE_PORT__QUEUE_SIZE:
				return queueSize != QUEUE_SIZE_EDEFAULT;
			case RTOSPackage.RUNNABLE_PORT__BLOCKING:
				return blocking != BLOCKING_EDEFAULT;
			case RTOSPackage.RUNNABLE_PORT__WAKING:
				return waking != WAKING_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (queueSize: ");
		result.append(queueSize);
		result.append(", blocking: ");
		result.append(blocking);
		result.append(", waking: ");
		result.append(waking);
		result.append(')');
		return result.toString();
	}

} //RunnablePortImpl
